package cn.kz.hrm.commonfeiclient;

import cn.kz.hrm.doc.CourseDoc;
import cn.kz.hrm.fallbackfactory.CommonFeignClientFallbackFactory;
import cn.kz.hrm.query.CourseQuery;
import cn.kz.hrm.util.AjaxResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

//feign的接口。fallbackFactory是降级方法。
@FeignClient(value = "common-server",fallbackFactory = CommonFeignClientFallbackFactory.class)
public interface CommonFeignClient {

    @RequestMapping(value = "/redis/set", method = RequestMethod.POST)
    AjaxResult setRedis(@RequestParam("key") String key, @RequestParam("value") String value);

    //根据key获取value值。
    @RequestMapping(value = "/redis/get/{key}",method = RequestMethod.GET)
    AjaxResult getRedis(@PathVariable("key") String key);

    //设置带有存储时间的redis。
    @RequestMapping(value = "/redis/setex", method = RequestMethod.POST)
    AjaxResult setRedisOutTime(@RequestParam("key") String key, @RequestParam("time") int time, @RequestParam("value") String value);

    @RequestMapping(value = "/redis/delete/{key}", method = RequestMethod.GET)
    AjaxResult deleteRedis(@PathVariable("key") String key);

    //elasticresach
    @RequestMapping(value = "/elasticresach/save/course", method = RequestMethod.POST)
    AjaxResult saveElasticReseach(@RequestBody CourseDoc courseDoc);

    //elasticresach
    @RequestMapping(value = "/elasticresach/delete/{id}", method = RequestMethod.POST)
    AjaxResult deleteElasticReseach(@PathVariable("id") long id);

    //elasticresach 查询课程的分类
    @RequestMapping(value = "/elasticresach/courseQuery", method = RequestMethod.POST)
    AjaxResult getQueryCourses(@RequestBody CourseQuery courseQuery);
}
